﻿using System;
using System.Collections.Generic;
using System.Globalization;

namespace Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.ViewModels
{
    public class RowAnalysisResultRowViewModelComparer : IComparer<object>
    {
        public int Compare(object x, object y)
        {
            if (x is int)
            {
                return Compare(Convert.ToInt32(x), Convert.ToInt32(y));
            }
            else
            {
                return Compare(Convert.ToString(x, CultureInfo.InvariantCulture), Convert.ToString(y, CultureInfo.InvariantCulture));
            }
        }

        private int Compare(int x, int y)
        {
            return x.CompareTo(y);
        }

        private int Compare(string x, string y)
        {
            return x.CompareTo(y);
        }
    }
}
